extends layout

block headContent
	title Bitcoin Explorer
	
block content


	- var tzDiff = -parseFloat(browserTzOffset);
	if (userTzOffset != "unset")
		- tzDiff = parseFloat(userTzOffset);

	- var tzMoment = moment.utc(new Date()).add(tzDiff, "hours");
	- var tzDay = tzMoment.format("MM-DD");

	if (global.btcHolidays.byDay[tzDay])
		
		- var day = tzDay;
		- var dom = parseInt(day.substring(3));
		- var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
		- var currentMonth = parseInt(day.substring(0, 2)) - 1;

		.mb-2
			+contentSection
				h5
					i.bi-star-fill.text-warning
					span.ms-2.fw-light.text-muted Today is...
				each item in global.btcHolidays.byDay[tzDay]
					h6.fs-5.text-uppercase.fw-light.text-card-highlight.mt-3 #{item.name}!
						span.ms-2 (#{months[currentMonth]} #{dom})
				
					.mb-0 !{item.desc}

	if (getblockchaininfo == null)
		div.alert.alert-danger
			h5.mb-3 Unable to get basic blockchain data
			ul
				li
					p
						b If you just started your node, it may still be initializing.
						div At startup, bitcoind verifies its block index before making itself available to serve data. The amount of time the verification process takes depends largely on the speed of the machine bitcoind is running on. If you're running bitcoind on low powered, inexpensive hardware, don't be surprised if this process takes a long time.
				li
					p
						b If you believe your bitcoind node is already initialized...
						div Check your RPC connection info and/or check this application's error log for possible hints about the cause of this issue.
	else

		+dismissableAlert("homepageWelcomeBannerDismissed")
			h5 Bitcoin Explorer
				span.fw-light :
					span.fst-italic.ms-1 The free, open-source, easy-to-setup, easy-to-use, self-hosted explorer
			

			span.fw-light Protect your privacy while enjoying the conveniences of public explorers. Made for Bitcoiners by Bitcoiners. Enjoy!

			hr

			.mt-2
				if (global.sourcecodeProjectMetadata)
					a.btn.btn-sm.btn-primary.mb-2.mb-md-1.me-3(href="https://github.com/janoside/btc-rpc-explorer", title="View source code", data-bs-toggle="tooltip", data-bs-placement="bottom")
						i.bi-git.fs-6.text-white.me-2
						| View Source

				a.btn.btn-sm.btn-primary.mb-2.mb-md-1.me-3(href="https://donate.bitcoinexplorer.org", target="_blank", title="Support this project with a donation", data-bs-toggle="tooltip", data-bs-placement="bottom")
					i.bi-heart-fill.fs-6.text-danger.me-2
					| Donate
					
				a.btn.btn-sm.btn-primary.mb-2.mb-md-1.me-3(href="https://twitter.com/BitcoinExplorer", target="_blank", title="Follow @BitcoinExplorer on Twitter", data-bs-toggle="tooltip", data-bs-placement="bottom")
					i.bi-twitter.fs-6.text-twitter.me-2
					| @BitcoinExplorer

		
		if (global.activeBlockchain == "main")
			if (getblockchaininfo.softforks && getblockchaininfo.softforks.taproot && getblockchaininfo.softforks.taproot.bip9)
				- var minTaprootHeight = getblockchaininfo.softforks.taproot.bip9.min_activation_height;
				- var blocksLeft = minTaprootHeight - getblockchaininfo.blocks;
				//- var blocksLeft = -145;

				if (blocksLeft > 0)
					+blockCountdown("Taproot Activation", blocksLeft)
						.mb-2 The softfork known as Taproot will activate on Bitcoin's mainnet at block height 709,632. After activation, any Bitcoin user will be able to use a new address type that enables new features and functionality. The Taproot upgrade has been ~4 years in the making!
						| Read more about Taproot's history from Pieter Wuille (one of its architects) <a href="https://twitter.com/pwuille/status/1403725170993336322">here</a>.

				else if (blocksLeft <= 0 && blocksLeft > -144)
					.alert.alert-success
						h5 Taproot: Activation Height Reached 🎉
						| Taproot has activated on Bitcoin's mainnet as of block height <a href="./block-height/709632">709,632</a>!
				

		if (getblockchaininfo.initialblockdownload && !["regtest", "signet"].includes(global.activeBlockchain))
			div.alert.alert-warning.shadow-sm.border.mb-3
				div.fw-bold.mb-1 Initial Block Download (IBD) - In Progress...

				div.mb-1 Your node is currently downloading and verifying blockchain data. Until the process is finished, some features of this tool will be unusable and/or unreliable.

				span.fw-bold Progress: 
				span #{new Decimal(getblockchaininfo.verificationprogress).times(100).toDP(3)}%


		
		include includes/index-network-summary.pug
		
		
		
		
						


		if (latestBlocks)
			.d-flex.justify-content-between
				div
					+sectionTitle("Latest Blocks")

				div
					a.small.ms-2(href="./blocks") Browse blocks &raquo;

			+contentSection
				- var blocks = latestBlocks;
				- var blockOffset = 0;

				include includes/blocks-list.pug
							

		+contentSection("Tools")
			include includes/tools-card.pug
				

block endOfBody
	script.
		var audio = new Audio('./audio/609335__kenneth_cooney__levelup.wav');
		var tipInfo = null;

		function refreshHalvingCountdownUI() {
			$.get("./snippet/index-halving-countdown", function(data) {
				$("#index-halving-countdown").html(data);
				enableTooltipsAndPopovers();
			});
		}

		function checkHalvingCountdown() {
			$.get("./api/blocks/tip", function(data) {
				if (data.height > tipInfo.height) {
					tipInfo = data;

					audio.play();

					refreshHalvingCountdownUI();
				}

				console.log(tipInfo);
			});
		}

		$(document).ready(function() {
			$.get("./snippet/next-block", function(data) {
				$("#index-next-block").html(data);
				enableTooltipsAndPopovers();
			});

			$.get("./api/blocks/tip", function(data) {
				tipInfo = data;
			});

			if ($("#index-halving-countdown-wrapper").length) {
				refreshHalvingCountdownUI();

				setInterval(checkHalvingCountdown, 3000);
			}
		});
		
